package org.university.entity;

import io.swagger.annotations.ApiModelProperty;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * @TableName classroom
 */
@Entity
@Table(name = "classroom")
@Data
public class Classroom implements Serializable {

    @Id
    @NotNull(message = "[]不能为空")
    @ApiModelProperty("")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer classroomId;
    /**
     * 所属楼
     */
    @NotBlank(message = "[所属楼]不能为空")
    @Size(max = 30, message = "编码长度不能超过30")
    @ApiModelProperty("所属楼")
    @Length(max = 30, message = "编码长度不能超过30")
    private String building;
    /**
     * 教室号
     */
    @NotNull(message = "[教室号]不能为空")
    @ApiModelProperty("教室号")
    private Integer roomNumber;
    /**
     * 最大容量
     */
    @NotNull(message = "[最大容量]不能为空")
    @ApiModelProperty("最大容量")
    private Integer capacity;
    /**
     * 教室类型
     */
    @NotNull(message = "[教室类型]不能为空")
    @ApiModelProperty("教室类型")
    @Enumerated(EnumType.STRING)
    private RoomType roomType;
    /**
     * 是否有投影仪
     */
    @ApiModelProperty("是否有投影仪")
    private Boolean hasProjector;
    /**
     * 是否有空调
     */
    @ApiModelProperty("是否有空调")
    private Boolean hasAirConditioner;

    @Column(name = "deleted", columnDefinition = "tinyint(1) default 0")
    @ApiModelProperty("是否已删除")
    private Integer deleted = 0;

    /**
     * 教室类型枚举
     */
    public enum RoomType {
        普通教室,
        实验室,
        阶梯教室,
        多媒体教室;
/*
        NORMAL("普通教室"),
        LAB("实验室"),
        THEATER("阶梯教室"),
        MULTIMEDIA("多媒体教室");
*/

/*
        private final String description;

        RoomType(String description) {
            this.description = description;
        }

        // 从数据库值转换
        public static RoomType fromDbValue(String dbValue) {
            for (RoomType type : values()) {
                if (type.description.equals(dbValue)) {
                    return type;
                }
            }
            throw new IllegalArgumentException("未知的教室类型: " + dbValue);
        }

        public String getDescription() {
            return description;
        }
*/
    }
}
